<?php
include('connexion.php');

function cleanText($intext)
{
    return utf8_encode(htmlspecialchars(stripslashes($intext)));
}
 
header("Content-Type: text/xml;charset=utf-8");
 
$query = mysql_query('SELECT * FROM news ORDER BY timestamp DESC');
$i = 10;
 
/* Code XML */
echo '<?xml version="1.0" encoding="iso-8859-1"?>';
echo '<rss version="2.0">';
echo '<channel>';
echo '<title>Stankoland - Les Articles</title>';
echo '<link>http://stankoland.online.fr</link>';
echo '<description>Les dernieres articles du blog de Stanko</description>';
echo '<language>fr-FR</language>';
echo '<managingEditor>romain.ferlet@gmail.com</managingEditor>';
echo '<webMaster>romain.ferlet@gmail.com</webMaster>';
 
while($row = mysql_fetch_assoc($query) and $i < 15)
{
    $title = cleanText($row['titre']);
    $description = substr(cleanText($row['contenu']),0,300);
    $pubDate = date('d/m/Y - H\hi', $row['timestamp']);
 
 
    echo '<item>';
    echo '<title>'.$title.'</title>';
    echo '<link>http://stankoland.online.fr/news.php?id='.$row['id'].'</link>';
    echo '<author>'.$mail.'</author>';
    echo '<description>'.$description.'</description>';
    echo '<pubDate>'.$pubDate.'</pubDate>';
    echo '</item>';
    $i++;
}
 
echo '</channel>';
echo '</rss>';
 
/* Fin du code XML */
 
mysql_close();
?>